package com.qyp.content.feignclient;

import com.qyp.content.domain.dto.user.UserDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(name = "user-center")
//@FeignClient(name = "user-center" , configuration = UserCenterFeignConfiguration.class)
public interface TestUserCenterFeignClient {

    /**推荐*/
    @GetMapping("/getUser1")
    UserDTO getUser1(@SpringQueryMap UserDTO userDTO);

    /**推荐这是最为直观的方式，URL有几个参数，Feign接口中的方法就有几个参数。使用@RequestParam注解指定请求的参数是什么*/
    @GetMapping("/getUser2")
    UserDTO getUser2(@RequestParam Integer id,@RequestParam String wxId);

    /**不推荐这种方式不建议使用。主要是因为可读性不好，而且如果参数为空的时候会有一些问题，
     * 例如map.put("username", null); 会导致microservice-provider-user 服务接收到的username是"" ，而不是null
     */
    @GetMapping("/getUser3")
    UserDTO getUser3(@RequestParam Map<String,Object> param);

    @GetMapping("/getUser4")
    UserDTO getUser4(@RequestBody UserDTO userDTO);

    @PostMapping("/postUser")
    UserDTO postUser(@RequestBody UserDTO userDTO);
}
